package com.feng.common.exception;


import com.feng.common.enums.ErrorCode;

/**
 * 业务异常类
 * @author: Jack.Cheng
 * @date: 2021/6/9 17:09
 */
public class BizException extends RuntimeException{

    /**
     * 异常状态码
     */
    private String code;
    /**
     * 异常消息
     */
    private String msg;

    public BizException(String code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public BizException(String code, String msg, Throwable cause) {
        super(msg, cause);
        this.code = code;
        this.msg = msg;
    }

    public BizException(ErrorCode errorCode) {
        super(errorCode.getMsg());
        this.code = errorCode.getCode();
        this.msg = errorCode.getMsg();
    }

    public BizException(ErrorCode errorCode, Throwable cause) {
        super(errorCode.getMsg(), cause);
        this.code = errorCode.getCode();
        this.msg = errorCode.getMsg();
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }
}
